package com.itheima.controller;


import com.itheima.pojo.Emp;
import com.itheima.pojo.LoginInfo;
import com.itheima.pojo.Result;
import com.itheima.service.EmpService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/login")
@Slf4j
public class LoginController {

    @Autowired
    EmpService empService;

    @PostMapping()
    public Result login(@RequestBody Emp emp) {
        log.info("login...");
        LoginInfo logininfo = empService.login(emp);
        if (logininfo != null) {
            return Result.success(logininfo);
        } else {
            return Result.error("登陆失败");
        }

    }
}
